package com.atguigu.eduservice.controller.admin;

import com.atguigu.commonutils.R;
import com.atguigu.eduservice.client.BannerClient;
import com.atguigu.eduservice.entity.CrmBanner;
import com.atguigu.eduservice.query.BannerQuery;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 首页banner表 前端控制器(后台管理使用)
 * </p>
 *
 * @author Mr.Alan
 * @since 2020-08-22
 */
@RestController
@RequestMapping("/cmsService/admin/banner")
@CrossOrigin
public class CrmBannerController {

    @Resource
    private BannerClient bannerClient;


    @ApiOperation("更新轮播图信息")
    @PostMapping("/update")
    public R update(@RequestBody CrmBanner banner) {
        return bannerClient.update(banner);
    }

    @ApiOperation("添加一个轮播图")
    @PostMapping("/save")
    public R save(@RequestBody CrmBanner banner) {
        return bannerClient.save(banner);
    }

    @PostMapping("/delete/{id}")
    @ApiOperation("通过ID删除轮播图")
    public R delete(@PathVariable("id") String id) {
        return bannerClient.delete(id);
    }

    @PostMapping("/page")
    @ApiOperation("分页查询轮图")
    public R pageBanner(@RequestBody BannerQuery query) {
        return bannerClient.pageBanner(query);
    }


}
